import { Injectable } from '@nestjs/common';
import * as svgCaptcha from 'svg-captcha';

@Injectable()
export class CaptchaService {
  generateCaptcha() {
    const captcha = svgCaptcha.create();
    return {
      text: captcha.text,
      image: captcha.data, // SVG 格式的验证码
    };
  }
} 

// import { Injectable } from '@nestjs/common';
// import { Captcha } from 'captcha-generator';

// @Injectable()
// export class CaptchaService {
//   generateCaptcha() {
//     const captcha = new Captcha();
//     const captchaText = captcha.getRandomText();
//     const captchaImage = captcha.create();

//     return {
//       text: captchaText,
//       image: captchaImage,
//     };
//   }
// } 